
function setspi()
    spi.setup(1, spi.MASTER, spi.CPOL_LOW, spi.CPHA_LOW, 8, 16,spi.FULLDUPLEX)

    cs  = 8 -- GPIO15, pull-down 10k to GND
    dc  = 4 -- GPIO2
    res = 0 -- GPIO16, RES is optional YMMV
    
    
    gpio.mode(cs, gpio.INPUT, gpio.PULLUP)
    
    disp = ucg.ili9341_18x240x320_hw_spi(cs, dc, res)
    
    disp:begin(ucg.FONT_MODE_TRANSPARENT)
    
    --disp:clearScreen()
    
    --disp:setColor(0, 255, 0, 0);
    --disp:setColor(1, 0, 255, 0);
    --disp:setColor(2, 255, 0, 255);
    --disp:setColor(3, 0, 255, 255);
    --disp:drawGradientBox(0, 0, 240, 320)
end

function settouch()
    -- SETTING UP TOUCH
    cs_pin  = 2 -- GPIO4
    irq_pin = 3 -- GPIO0
    height  = 240
    width = 320
    xpt2046.init(cs_pin, irq_pin, width, height)
    --xpt2046.setCalibration(198, 1776, 1762, 273)
    xpt2046.setCalibration(1920, 0, 128, 1984)
    gpio.mode(irq_pin,gpio.INT,gpio.PULLUP)
end
